package com.sophialex.health.record.common.bind.model;

import com.sophia.pojo.AbstractModelObject;

import net.sf.cglib.proxy.Enhancer;
/**
 * @author sunxq
 * 用于包装包装领域类，为其setter触发属性更改事件
 * 若不经过此类包装，此不能完成模型到UI的更新
 */
public class BeanFactory {
	
	//包装领域类，为其setter触发属性更改事件
	@SuppressWarnings("unchecked")
	public static <T extends AbstractModelObject> T proxyBean(T bean,Class beanClass) {
		Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(beanClass);
        enhancer.setCallback(new BeanInterceptor());
        //enhancer.setCallbackFilter(new AuthProxyFilter());
        return (T) enhancer.create();

		
    }


}
